<?php

namespace App\Http\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model;

class BannerApiModel extends Model
{
    use HasDateTimeFormatter;

    protected $table = 'banner';

    public function getImgAttribute($img)
    {
        return env('APP_URL') . '/uploads/' . $img;
    }

    /**
     *只查询状态为1的数据
     *
     * @param  \Illuminate\Database\Eloquent\Builder  $query
     * @return \Illuminate\Database\Eloquent\Builder
     */
    public function scopeStatus($query)
    {
        $filds = ['id', 'img'];
        return $query->select($filds)->where('status', '=', 1);
    }
}
